home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.alaska-software.com
/
2014.06.ftp.alaska-software.com.tar
/
ftp.alaska-software.com
/
3pp
/
mxsetup.old
/
{app}
/
MxGoodies.prg
< prev
next >
Wrap
Text File
|
2001-09-25
|
6KB
|
203 lines
//////////////////////////////////////////////////////////////////////
//
// MxGoodies.PRG
//
// Copyright:
// Maniacc Software Inc., (c) 2001. All rights reserved.
//
// Contents:
// Special Routines
// MxUnique( cClass, cProgName, cTitle ) - Prevents multiples
// of the same App.
// GetLongFileName( cShortName, lPath ) - Gets the Long File
// Name from the Short
// File Name (8.3)
// GetShortFileName( cLongName ) - Gets the Short File
// Name (8.3) from the
// Short File Name
// AllWindows() - Display Title of All
// Top Level Windows
// MxMail( cMailto, cSubject, cBody ) - Starts the Mail Handler.
// ShellOpenFile( cFile ) - Call ShellExecute()
//
//////////////////////////////////////////////////////////////////////
#include "Dll.ch"
#INCLUDE "Bap.ch"
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_MAX 10
DLLFUNCTION FindWindowA( @ClassName, WinName ) USING STDCALL FROM USER32.DLL
DLLFUNCTION GetForegroundWindow() USING STDCALL FROM USER32.DLL
DLLFUNCTION IsIconic( nHwnd ) USING STDCALL FROM USER32.DLL
DLLFUNCTION GetLastActivePopup( nHwnd ) USING STDCALL FROM USER32.DLL
DLLFUNCTION ShowWindow( nHwnd, nCmdShow ) USING STDCALL FROM USER32.DLL
DLLFUNCTION BringWindowToTop( nHwnd ) USING STDCALL FROM USER32.DLL
DLLFUNCTION SetForegroundWindow( nHwnd ) USING STDCALL FROM USER32.DLL
DLLFUNCTION GetWindowThreadProcessId( nForgroundHwnd, @nRetProcId ) USING STDCALL FROM USER32.DLL
DLLFUNCTION CreateMutexA( SecAttr, nInitialOwn, cName ) USING STDCALL FROM KERNEL32.DLL
DLLFUNCTION GetLastError() USING STDCALL FROM KERNEL32.DLL
PROCEDURE MxUnique( cClass, cProgName, cTitle )
LOCAL nHwndFind, nHwndForeground, nForegroundId
LOCAL nFindThreadId, nHwndLast
LOCAL lRet
nHwndFind := FindWindowA( @cClass, @cTitle )
CreateMutexA(0,1,cProgName)
if GetLastError() == 183
nFindThreadId := GetWindowThreadProcessId( nHwndFind, 0 )
nHwndForeground := GetForegroundWindow()
nForeGroundId := GetWindowThreadProcessId( nHwndForeground, 0 )
if nForeGroundId <> nFindThreadId .or. IsIconic( nHwndFind ) <> 0
nHwndLast := GetLastActivePopup( nHwndFind )
if IsIconic( nHwndLast ) <> 0
ShowWindow( nHwndLast, SW_RESTORE )
endif
BringWindowToTop( nHwndLast )
SetForegroundWindow( nHwndLast )
endif
QUIT
endif
RETURN
***************************************************
FUNCTION GetLongFileName( cShortName, lPath )
LOCAL lFullPath := iif(empty(lPath), .F., lPath)
LOCAL cFileName := iif(empty(cShortName), "", alltrim(cShortName))
LOCAL lEndSlash := iif(right(cFileName, 1)=="\",.T.,.F.)
LOCAL cLongName := iif(lEndSlash, left(cFileName, len(cFileName) - 1), cFileName)
LOCAL cPathName := left(cLongName, rat("\", cLongName))
LOCAL aDir := Directory(cLongName, "DHS")
if right(cLongName, 1) == ":"
cLongName := upper(cLongName) + iif(lEndSlash, "\", "")
elseif len(aDir) == 1
cLongName := alltrim(aDir[1, F_NAME])
else
cLongName := iif(lEndSlash, "\", "")
endif
if lFullPath
cLongName := GetLongFileName(cPathName, ("\" $ cPathName)) + cLongName + iif(lEndSlash, "\", "")
endif
RETURN cLongName
***************************************************
FUNCTION GetShortFileName( cLongName )
LOCAL cShortName := space(255)
LOCAL nLen := 1
if empty( cLongName )
cShortName := ""
else
nLen := DllCall("Kernel32.DLL", DLL_STDCALL, "GetShortPathNameA", ;
cLongName, @cShortName, len(cShortName))
cShortName := left(cShortName, nLen)
endif
RETURN cShortName
******************************************************
******************************************************
* AllWindows - Display Title of All Top Level Windows
******************************************************
DLLFUNCTION EnumWindows( cProc, nPara ) USING STDCALL FROM USER32.DLL
DLLFUNCTION GetWindowTextA( nHandle, @cBuf, nSize ) USING STDCALL FROM USER32.DLL
FUNCTION AllWindows()
LOCAL i
PRIVATE aTitles := {}, cTitles := ""
EnumWindows(BaCallBack("EnumWindow",BA_CB_LPOFNHOOKPROC),0)
if !empty(aTitles)
for i := 1 to len(aTitles)
cTitles := cTitles+aTitles[i]
if i<len(aTitles)
cTitles := cTitles+chr(13)
endif
next i
// MsgBox( cTitles, "Desktop Window Titles" )
MxMsgBox( cTitles, "Desktop Window Titles", "C" )
endif
RETURN .T.
******************************************************
FUNCTION EnumWindow( nHandle, nr )
LOCAL cBuf := repl(chr(32),100)
LOCAL nLen := len(cBuf)
nLen := GetWindowTextA( nHandle, @cBuf, nLen )
if nLen > 0
// MsgBox(left(cBuf,nLen))
// MxMsgBox(left(cBuf,nLen))
aAdd(aTitles,left(cBuf,nLen))
endif
RETURN 1
******************************************************
******************************************************
* MxMail( cMailto, cSubject, cBody, cAttachment )
******************************************************
******************************************************
FUNCTION MxMail( cMailto, cSubject, cBody )
LOCAL cFile := "mailto:"+cMailto+;
" ?subject="+cSubject+;
" &body="+cBody
DllCall( "SHELL32.DLL" ,;
DLL_STDCALL, "ShellExecuteA", AppDesktop():getHWND(), "Open", cFile, Nil, Curdir(), SW_NORMAL )
RETURN .T.
******************************************************
PROCEDURE ShellOpenFile( cFile )
DllCall( "SHELL32.DLL" ,;
DLL_STDCALL, "ShellExecuteA", AppDesktop():getHWND(), "Open", cFile, Nil, Curdir(), SW_NORMAL )
RETURN